<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 原型继承公共部分
        function People() {
            this.head = 1;
            this.eyes = 2;
            this.legs = 2;
        }
        function Man() {
        }
        function Woman() {
        }
        Man.prototype = new People()
        // 用完后要指回来因为赋值导致对象原型指向改变
        Man.prototype.constructor = Man

        Woman.prototype = new People()
        // 用完后要指回来因为赋值导致对象原型指向改变
        Woman.prototype.constructor = Woman


        // 给其中某构造函数添加属性或方法
        Woman.prototype.pig = '你是猪'
        Woman.prototype.big = function () {
            console.log('猪队友');
        }

        const chun = new Man()
        const xuan = new Woman()

        console.log(chun);
        console.log(xuan);

    </script>
</body>

</html>